﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;

namespace HomeHealthWebService
{
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the interface name "IService1" in both code and config file together.
    [ServiceContract]
    public interface IHomeHealthService
    {

        [OperationContract]
        [WebInvoke(UriTemplate = "Patient", Method = "POST", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
        Patient InsertNewPatient(Patient newPatient);

        [OperationContract]
        [WebGet(UriTemplate = "Patient", ResponseFormat = WebMessageFormat.Json)]
        List<Patient> GetAllPatient();

        [OperationContract]
        [WebGet(UriTemplate = "Patient?id={id}", ResponseFormat = WebMessageFormat.Json)]
        Patient GetAPatient(string id);

        [OperationContract]
        [WebInvoke(UriTemplate = "Patient?id={id}", Method = "PUT", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
        Patient UpdatePatient(string id, Patient updatePatient);

        [OperationContract]
        [WebInvoke(UriTemplate = "Patient?id={id}", Method = "DELETE", ResponseFormat = WebMessageFormat.Json)]
        void DeletePatient(string id);

        [OperationContract]
        [WebInvoke(UriTemplate = "Nurse", Method = "POST", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
        Nurse InsertNewNurse(Nurse newNurse);

        [OperationContract]
        [WebGet(UriTemplate = "Nurse", ResponseFormat = WebMessageFormat.Json)]
        List<Nurse> GetAllNurse();

        [OperationContract]
        [WebGet(UriTemplate = "Nurse?id={id}", ResponseFormat = WebMessageFormat.Json)]
        Nurse GetANurse(string id);

        [OperationContract]
        [WebInvoke(UriTemplate = "Nurse?id={id}", Method = "PUT", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
        Nurse UpdateNurse(string id, Nurse updateNurse);

        [OperationContract]
        [WebInvoke(UriTemplate = "Nurset?id={id}", Method = "DELETE", ResponseFormat = WebMessageFormat.Json)]
        void DeleteNurse(string id);

        [OperationContract]
        [WebInvoke(UriTemplate = "Physician", Method = "POST", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
        Physician InsertNewPhysician(Physician newPhysician);

        [OperationContract]
        [WebGet(UriTemplate = "Physician", ResponseFormat = WebMessageFormat.Json)]
        List<Physician> GetAllPhysician();

        [OperationContract]
        [WebGet(UriTemplate = "Physician?id={id}", ResponseFormat = WebMessageFormat.Json)]
        Physician GetAPhysician(string id);

        [OperationContract]
        [WebInvoke(UriTemplate = "Physician?id={id}", Method = "PUT", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
        Physician UpdatePhysician(string id, Physician updateNurse);

        [OperationContract]
        [WebInvoke(UriTemplate = "Physician?id={id}", Method = "DELETE", ResponseFormat = WebMessageFormat.Json)]
        void DeletePhysician(string id);

        [OperationContract]
        [WebInvoke(UriTemplate = "SicknessHistory?patient={id}", Method = "GET", ResponseFormat = WebMessageFormat.Json)]
        List<SicknessHistory> GetSicknessHistory(string id);
    }

    [DataContract]
    public class Patient
    {
        [DataMember]
        public string PatientID;

        [DataMember]
        public string Name;

        [DataMember]
        public string DateOfBirth;

        [DataMember]
        public string PlaceOfBirth;

        [DataMember]
        public string IDNo;

        [DataMember]
        public string MaritalStatus;

        [DataMember]
        public string Address;

        [DataMember]
        public string PhysicianID;

        [DataMember]
        public string NurseID;

        [DataMember]
        public string PhoneNumber;

        [DataMember]
        public string StatusType;

        [DataMember]
        public string CreateDate;

        [DataMember]
        public string UpdateDate;
    }

    [DataContract]
    public class Nurse
    {
        [DataMember]
        public string ID;

        [DataMember]
        public string Name;

        [DataMember]
        public string PhoneNumber;

        [DataMember]
        public string Address;

        [DataMember]
        public string Specialist;

        [DataMember]
        public string Hospital;

        [DataMember]
        public string HospitalHotline;

        [DataMember]
        public string CreateDate;

        [DataMember]
        public string UpdateDate;
    }

    [DataContract]
    public class Physician
    {
        [DataMember]
        public string ID;

        [DataMember]
        public string Name;

        [DataMember]
        public string PhoneNumber;

        [DataMember]
        public string Address;

        [DataMember]
        public string Specialist;

        [DataMember]
        public string Hospital;

        [DataMember]
        public string HospitalHotline;

        [DataMember]
        public string CreateDate;

        [DataMember]
        public string UpdateDate;
    }

    [DataContract]
    public class SicknessHistory
    {
        [DataMember]
        public string ID;

        [DataMember]
        public string Disease;

        [DataMember]
        public string Time;

        [DataMember]
        public string Symtom;

        [DataMember]
        public string Body;

        [DataMember]
        public string Cause;

        [DataMember]
        public string NurseID;

        [DataMember]
        public string Patient;

        [DataMember]
        public string Medication;

        [DataMember]
        public string Remark;
    }
}
